package com.dao.impl;

import static com.def.GenericDef.E_XPBISPAM_MDL_NOT_FOUNCT;
import static com.def.GenericDef.E_XPBISPAM_NOT_FOUND_RECORDER;
import static com.def.GenericDef.E_XPBISPAM_RECORDER_ALREADY_EXIST;
import static com.def.GenericDef.E_XPWOTOOL_NOT_FOUND_RECORDER;
import static com.def.GenericDef.RETURN_CODE_OK;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.dao.IBisPamDao;
import com.model.Bis_pam;
import com.model.Bis_pamId;
import com.tx.Xpbispam.XpbispamI;
import com.tx.Xpbispam.XpbispamIA;
import com.tx.Xpbispam.XpbispamO;
import com.tx.Xpbispam.XpbispamOA;
 
@Repository
public class BisPamHibernateDao extends GenericHibernateDao<Bis_pam, Bis_pamId> 
implements IBisPamDao
{
	public XpbispamO queryByCondition(XpbispamI xpbismtlI){
		/***
		 * 支持
		 *   
		 *   by bay_id,wo_id_fk,ope_id_fk 查询
		 *   
		 * **/
		 
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		List<XpbispamOA> oaryList = new ArrayList<XpbispamOA> ();
		
		XpbispamIA iary = xpbismtlI.getIary().get(0);
		String tool_id_fk=iary.getTool_id_fk();
		String mdl_typ_fk=iary.getMdl_typ_fk();
		String mdl_id_fk=iary.getMdl_id_fk();
		String path_id_fk=iary.getPath_id_fk();
		String path_ver_fk=iary.getPath_ver_fk();
		String ope_no_fk=iary.getOpe_no_fk();
		String ope_id_fk=iary.getOpe_id_fk();
		String ope_ver_fk=iary.getOpe_ver_fk();
		
		String hql ="FROM Bis_pam where 1=1 ";
		if( tool_id_fk !=null){
//			if( tool_id_fk.indexOf('*')==-1){
//				hql = hql + " and tool_id_fk='" + tool_id_fk + "'";
//			}else{
//				hql = hql + " and tool_id_fk like '" + tool_id_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and tool_id_fk='" + tool_id_fk + "'";
			
		}
		if( mdl_typ_fk !=null){
//			if( mdl_typ_fk.indexOf('*')==-1){
//				hql = hql + " and mdl_typ_fk='" + mdl_typ_fk + "'";
//			}else{
//				hql = hql + " and mdl_typ_fk like '" + mdl_typ_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and mdl_typ_fk ='"+ mdl_typ_fk +"'" ;
			
		}
		if( mdl_id_fk !=null){
//			if( mdl_id_fk.indexOf('*')==-1){
//				hql = hql + " and mdl_id_fk='" + mdl_id_fk + "'";
//			}else{
//				hql = hql + " and mdl_id_fk like '" + mdl_id_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and mdl_id_fk ='"+ mdl_id_fk +"'" ;
			
		}
		if( path_id_fk !=null){
//			if( path_id_fk.indexOf('*')==-1){
//				hql = hql + " and path_id_fk='" + path_id_fk + "'";
//			}else{
//				hql = hql + " and path_id_fk like '" + path_id_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and path_id_fk ='"+ path_id_fk +"'" ;
			
		}
		if( path_ver_fk !=null){
//			if( path_ver_fk.indexOf('*')==-1){
//				hql = hql + " and path_ver_fk='" + path_ver_fk + "'";
//			}else{
//				hql = hql + " and path_ver_fk like '" + path_ver_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and path_ver_fk ='"+ path_ver_fk +"'" ;
			
		}
		if( ope_no_fk !=null){
//			if( ope_no_fk.indexOf('*')==-1){
//				hql = hql + " and ope_no_fk='" + ope_no_fk + "'";
//			}else{
//				hql = hql + " and ope_no_fk like '" + ope_no_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and ope_no_fk ='"+ ope_no_fk +"'" ;
			
		}
		if( ope_id_fk !=null){
//			if( ope_id_fk.indexOf('*')==-1){
//				hql = hql + " and ope_id_fk='" + ope_id_fk + "'";
//			}else{
//				hql = hql + " and ope_id_fk like '" + ope_id_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and ope_id_fk ='"+ ope_id_fk +"'" ;
			
		}
		if( ope_ver_fk !=null){
//			if( ope_ver_fk.indexOf('*')==-1){
//				hql = hql + " and ope_ver_fk='" + ope_ver_fk + "'";
//			}else{
//				hql = hql + " and ope_ver_fk like '" + ope_ver_fk.replace('*', '%') + "'";
//			}
			hql = hql + " and ope_ver_fk ='"+ ope_ver_fk +"'" ;
			
		}
		hql = hql +" order by mdl_typ_fk,mdl_id_fk,path_id_fk,path_ver_fk," +
				"ope_no_fk,ope_id_fk,ope_ver_fk,tool_id_fk";
		List<Bis_pam> bisPamList =this.find( hql );
		
		for(Bis_pam bis_pam : bisPamList){
			XpbispamOA oary = new XpbispamOA();
			oary.setTool_id_fk(bis_pam.getId().getTool_id_fk());
			oary.setMdl_typ_fk(bis_pam.getId().getMdl_typ_fk());
			oary.setMdl_id_fk(bis_pam.getId().getMdl_id_fk());
			oary.setPath_id_fk(bis_pam.getId().getPath_id_fk());
			oary.setPath_ver_fk(bis_pam.getId().getPath_ver_fk());
			oary.setOpe_id_fk(bis_pam.getId().getOpe_id_fk());
			oary.setOpe_no_fk(bis_pam.getId().getOpe_no_fk());
			oary.setOpe_ver_fk(bis_pam.getId().getOpe_ver_fk());
			oary.setRecipe_id(bis_pam.getRecipe_id());
			oary.setActive_flg(bis_pam.getActive_flg());
			oary.setSkip_flg(bis_pam.getSkip_flg());
			oary.setMes_id(bis_pam.getMes_id());
			oary.setBox_set_code(bis_pam.getBox_set_code());
			oary.setGd_judge_flg(bis_pam.getGd_judge_flg());
			oary.setDef_judge_flg(bis_pam.getDef_judge_flg());
			oary.setSwh_cnt_add_flg(bis_pam.getSwh_cnt_add_flg());
			oary.setSwh_cnt_add_pos(bis_pam.getSwh_cnt_add_pos());
			oary.setSwh_max_cnt(bis_pam.getSwh_max_cnt());
			oaryList.add(oary);
		}
		xpbispamO.setOary(oaryList);
		xpbispamO.setTbl_cnt(oaryList.size());
		xpbispamO.setRtn_code(RETURN_CODE_OK);
		xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	public XpbispamO listDistinctFnc(XpbispamI xpbismtlI){
		/***
		 * 支持
		 *   
		 *   by bay_id,wo_id_fk,ope_id_fk 查询
		 *   
		 * **/
		 
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		List<XpbispamOA> oaryList = new ArrayList<XpbispamOA> ();
		
		XpbispamIA iary = xpbismtlI.getIary().get(0);
		String tool_id_fk=iary.getTool_id_fk();
		String mdl_typ_fk=iary.getMdl_typ_fk();
		String mdl_id_fk=iary.getMdl_id_fk();
		String path_id_fk=iary.getPath_id_fk();
		String path_ver_fk=iary.getPath_ver_fk();
		String ope_no_fk=iary.getOpe_no_fk();
		String ope_id_fk=iary.getOpe_id_fk();
		String ope_ver_fk=iary.getOpe_ver_fk();
		
		String hql ="FROM Bis_pam where 1=1 ";
		if( tool_id_fk !=null){
			if( tool_id_fk.indexOf('*')==-1){
				hql = hql + " and tool_id_fk='" + tool_id_fk + "'";
			}else{
				hql = hql + " and tool_id_fk like '" + tool_id_fk.replace('*', '%') + "'";
			}
//			hql = hql + " tool_id_fk ='"+ tool_id_fk +"'" ;
			
		}
		if( mdl_typ_fk !=null){
			if( mdl_typ_fk.indexOf('*')==-1){
				hql = hql + " and mdl_typ_fk='" + mdl_typ_fk + "'";
			}else{
				hql = hql + " and mdl_typ_fk like '" + mdl_typ_fk.replace('*', '%') + "'";
			}
//			hql = hql + " mdl_typ_fk ='"+ mdl_typ_fk +"'" ;
			
		}
		if( mdl_id_fk !=null){
			if( mdl_id_fk.indexOf('*')==-1){
				hql = hql + " and mdl_id_fk='" + mdl_id_fk + "'";
			}else{
				hql = hql + " and mdl_id_fk like '" + mdl_id_fk.replace('*', '%') + "'";
			}
//			hql = hql + " mdl_id_fk ='"+ mdl_id_fk +"'" ;
			
		}
		if( path_id_fk !=null){
			if( path_id_fk.indexOf('*')==-1){
				hql = hql + " and path_id_fk='" + path_id_fk + "'";
			}else{
				hql = hql + " and path_id_fk like '" + path_id_fk.replace('*', '%') + "'";
			}
//			hql = hql + " path_id_fk ='"+ path_id_fk +"'" ;
			
		}
		if( path_ver_fk !=null){
			if( path_ver_fk.indexOf('*')==-1){
				hql = hql + " and path_ver_fk='" + path_ver_fk + "'";
			}else{
				hql = hql + " and path_ver_fk like '" + path_ver_fk.replace('*', '%') + "'";
			}
//			hql = hql + " path_ver_fk ='"+ path_ver_fk +"'" ;
			
		}
		if( ope_no_fk !=null){
			if( ope_no_fk.indexOf('*')==-1){
				hql = hql + " and ope_no_fk='" + ope_no_fk + "'";
			}else{
				hql = hql + " and ope_no_fk like '" + ope_no_fk.replace('*', '%') + "'";
			}
//			hql = hql + " ope_no_fk ='"+ ope_no_fk +"'" ;
			
		}
		if( ope_id_fk !=null){
			if( ope_id_fk.indexOf('*')==-1){
				hql = hql + " and ope_id_fk='" + ope_id_fk + "'";
			}else{
				hql = hql + " and ope_id_fk like '" + ope_id_fk.replace('*', '%') + "'";
			}
//			hql = hql + " ope_id_fk ='"+ ope_id_fk +"'" ;
			
		}
		if( ope_ver_fk !=null){
			if( ope_ver_fk.indexOf('*')==-1){
				hql = hql + " and ope_ver_fk='" + ope_ver_fk + "'";
			}else{
				hql = hql + " and ope_ver_fk like '" + ope_ver_fk.replace('*', '%') + "'";
			}
//			hql = hql + " ope_ver_fk ='"+ ope_ver_fk +"'" ;
			
		}
		hql = hql +" order by mdl_typ_fk,mdl_id_fk,path_id_fk,path_ver_fk," +
				"ope_no_fk,ope_id_fk,ope_ver_fk,tool_id_fk";
		List<Bis_pam> bisPamList =this.find( hql );
		String mdl_typ_fk2  ="";
		String mdl_id_fk2   ="";
		String path_id_fk2  ="";
		String path_ver_fk2 ="";
		String ope_id_fk2   ="";
		String ope_no_fk2   ="";
		String ope_ver_fk2  ="";
		
		for(Bis_pam bis_pam : bisPamList){
			XpbispamOA oary = new XpbispamOA();
			if(       bis_pam.getId().getMdl_typ_fk().equals(mdl_typ_fk2)
					&&bis_pam.getId().getMdl_id_fk().equals(mdl_id_fk2)
					&&bis_pam.getId().getPath_id_fk().equals(path_id_fk2)
					&&bis_pam.getId().getPath_ver_fk().equals(path_ver_fk2)
					&&bis_pam.getId().getOpe_id_fk().equals(ope_id_fk2)
					&&bis_pam.getId().getOpe_no_fk().equals(ope_no_fk2)
					&&bis_pam.getId().getOpe_ver_fk().equals(ope_ver_fk2)
					){
				continue;
			}
			oary.setTool_id_fk(bis_pam.getId().getTool_id_fk());
			oary.setMdl_typ_fk(bis_pam.getId().getMdl_typ_fk());
			oary.setMdl_id_fk(bis_pam.getId().getMdl_id_fk());
			oary.setPath_id_fk(bis_pam.getId().getPath_id_fk());
			oary.setPath_ver_fk(bis_pam.getId().getPath_ver_fk());
			oary.setOpe_id_fk(bis_pam.getId().getOpe_id_fk());
			oary.setOpe_no_fk(bis_pam.getId().getOpe_no_fk());
			oary.setOpe_ver_fk(bis_pam.getId().getOpe_ver_fk());
			oary.setRecipe_id(bis_pam.getRecipe_id());
			oary.setActive_flg(bis_pam.getActive_flg());
			oary.setSkip_flg(bis_pam.getSkip_flg());
			oary.setMes_id(bis_pam.getMes_id());
			oary.setBox_set_code(bis_pam.getBox_set_code());
			oary.setGd_judge_flg(bis_pam.getGd_judge_flg());
			oary.setDef_judge_flg(bis_pam.getDef_judge_flg());
			oary.setSwh_cnt_add_flg(bis_pam.getSwh_cnt_add_flg());
			oary.setSwh_cnt_add_pos(bis_pam.getSwh_cnt_add_pos());
			oary.setSwh_max_cnt(bis_pam.getSwh_max_cnt());
			oaryList.add(oary);
		    mdl_typ_fk2  = bis_pam.getId().getMdl_typ_fk();
		    mdl_id_fk2   = bis_pam.getId().getMdl_id_fk();
		    path_id_fk2  = bis_pam.getId().getPath_id_fk();
		    path_ver_fk2 = bis_pam.getId().getPath_ver_fk();
		    ope_id_fk2   = bis_pam.getId().getOpe_id_fk();
		    ope_no_fk2   = bis_pam.getId().getOpe_no_fk();
		    ope_ver_fk2  = bis_pam.getId().getOpe_ver_fk();
		}
		xpbispamO.setOary(oaryList);
		xpbispamO.setTbl_cnt(oaryList.size());
		xpbispamO.setRtn_code(RETURN_CODE_OK);
		xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	
	public XpbispamO addProc(XpbispamI xpwotoolI){
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		
		XpbispamIA iary = xpwotoolI.getIary().get(0);
		String tool_id_fk=iary.getTool_id_fk();
		String mdl_id_fk=iary.getMdl_id_fk();
		String mdl_typ_fk =(("*").equals(mdl_id_fk))? "*" : getMdlTypByMdlIDProc(mdl_id_fk);
		if(mdl_typ_fk == null){
			xpbispamO.setRtn_code(E_XPBISPAM_MDL_NOT_FOUNCT+"");
			xpbispamO.setRtn_mesg("not found mdl_id["+mdl_id_fk +"]");
			return xpbispamO;
		}
		String path_id_fk=iary.getPath_id_fk();
		String path_ver_fk=iary.getPath_ver_fk();
		String ope_no_fk=iary.getOpe_no_fk();
		String ope_id_fk=iary.getOpe_id_fk();
		String ope_ver_fk=iary.getOpe_ver_fk();
		
		Bis_pamId id = new Bis_pamId();
		id.setTool_id_fk(tool_id_fk);
		id.setMdl_id_fk(mdl_id_fk);
		id.setMdl_typ_fk(mdl_typ_fk);
		id.setPath_id_fk(path_id_fk);
		id.setPath_ver_fk(path_ver_fk);
		id.setOpe_no_fk(ope_no_fk);
		id.setOpe_id_fk(ope_id_fk);
		id.setOpe_ver_fk(ope_ver_fk);
		
		Bis_pam queryBisPam = this.get(id);
		if( queryBisPam != null){
			xpbispamO.setRtn_code(E_XPBISPAM_RECORDER_ALREADY_EXIST+"");
			xpbispamO.setRtn_mesg("Record already Exist");
			return xpbispamO;
		}
		Bis_pam bis_pam = new Bis_pam();
		bis_pam.setId(id);
		bis_pam.setRecipe_id(iary.getRecipe_id());
		bis_pam.setActive_flg(iary.getActive_flg());
		bis_pam.setSkip_flg(iary.getSkip_flg());
		bis_pam.setMes_id(iary.getMes_id());
		bis_pam.setBox_set_code(iary.getBox_set_code());
		bis_pam.setGd_judge_flg(iary.getGd_judge_flg());
		bis_pam.setDef_judge_flg(iary.getDef_judge_flg());
		bis_pam.setSwh_cnt_add_flg(iary.getSwh_cnt_add_flg());
		bis_pam.setSwh_cnt_add_pos(iary.getSwh_cnt_add_pos());
		bis_pam.setSwh_max_cnt(iary.getSwh_max_cnt());
        this.save(bis_pam);
        
        xpbispamO.setRtn_code(RETURN_CODE_OK);
        xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	public XpbispamO updateProc(XpbispamI xpwotoolI){
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		
		XpbispamIA iary = xpwotoolI.getIary().get(0);
		String tool_id_fk=iary.getTool_id_fk();
		String mdl_id_fk=iary.getMdl_id_fk();
		String mdl_typ_fk =(("*").equals(mdl_id_fk))? "*" : getMdlTypByMdlIDProc(mdl_id_fk);
		if(mdl_typ_fk == null){
			xpbispamO.setRtn_code(E_XPBISPAM_MDL_NOT_FOUNCT+"");
			xpbispamO.setRtn_mesg("not found mdl_id["+mdl_id_fk +"]");
			return xpbispamO;
		}
		String path_id_fk=iary.getPath_id_fk();
		String path_ver_fk=iary.getPath_ver_fk();
		String ope_no_fk=iary.getOpe_no_fk();
		String ope_id_fk=iary.getOpe_id_fk();
		String ope_ver_fk=iary.getOpe_ver_fk();
		
		Bis_pamId id = new Bis_pamId();
		id.setTool_id_fk(tool_id_fk);
		id.setMdl_id_fk(mdl_id_fk);
		id.setMdl_typ_fk(mdl_typ_fk);
		id.setPath_id_fk(path_id_fk);
		id.setPath_ver_fk(path_ver_fk);
		id.setOpe_no_fk(ope_no_fk);
		id.setOpe_id_fk(ope_id_fk);
		id.setOpe_ver_fk(ope_ver_fk);
		
		Bis_pam bis_pam =getDataByKeyProc(id);
		if( bis_pam == null){
			xpbispamO.setRtn_code(E_XPBISPAM_NOT_FOUND_RECORDER+"");
			xpbispamO.setRtn_mesg("not found record");
			return xpbispamO;
		}
		//获取主键
		bis_pam.setId(id);
		if(iary.getRecipe_id()!=null){
			bis_pam.setRecipe_id(iary.getRecipe_id());
		}
		if(iary.getActive_flg()!=null){
			bis_pam.setActive_flg(iary.getActive_flg());
		}
		if(iary.getSkip_flg()!=null){
			bis_pam.setSkip_flg(iary.getSkip_flg());
		}
		if(iary.getMes_id()!=null){
			bis_pam.setMes_id(iary.getMes_id());
		}
		if(iary.getBox_set_code()!=null){
			bis_pam.setBox_set_code(iary.getBox_set_code());
		}
		if(iary.getGd_judge_flg()!=null){
			bis_pam.setGd_judge_flg(iary.getGd_judge_flg());
		}
		if(iary.getDef_judge_flg()!=null){
			bis_pam.setDef_judge_flg(iary.getDef_judge_flg());
		}
		if(iary.getSwh_cnt_add_flg()!=null){
			bis_pam.setSwh_cnt_add_flg(iary.getSwh_cnt_add_flg());
		}
		if(iary.getSwh_cnt_add_pos()!=null){
			bis_pam.setSwh_cnt_add_pos(iary.getSwh_cnt_add_pos());
		}
		if(iary.getSwh_max_cnt()!=null){
			bis_pam.setSwh_max_cnt(iary.getSwh_max_cnt());
		}
        this.update(bis_pam);
        
        xpbispamO.setRtn_code(RETURN_CODE_OK);
        xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	public XpbispamO deleteProc(XpbispamI xpwotoolI){
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		XpbispamIA iary = xpwotoolI.getIary().get(0);
		
		String tool_id_fk=iary.getTool_id_fk();
		String mdl_id_fk=iary.getMdl_id_fk();
		String mdl_typ_fk = (("*").equals(mdl_id_fk))? "*" : getMdlTypByMdlIDProc(mdl_id_fk);
		if(mdl_typ_fk == null){
			xpbispamO.setRtn_code(E_XPBISPAM_MDL_NOT_FOUNCT+"");
			xpbispamO.setRtn_mesg("not found mdl_id["+mdl_id_fk +"]");
			return xpbispamO;
		}
		String path_id_fk=iary.getPath_id_fk();
		String path_ver_fk=iary.getPath_ver_fk();
		String ope_no_fk=iary.getOpe_no_fk();
		String ope_id_fk=iary.getOpe_id_fk();
		String ope_ver_fk=iary.getOpe_ver_fk();
		
		Bis_pamId id = new Bis_pamId();
		id.setTool_id_fk(tool_id_fk);
		id.setMdl_id_fk(mdl_id_fk);
		id.setMdl_typ_fk(mdl_typ_fk);
		id.setPath_id_fk(path_id_fk);
		id.setPath_ver_fk(path_ver_fk);
		id.setOpe_no_fk(ope_no_fk);
		id.setOpe_id_fk(ope_id_fk);
		id.setOpe_ver_fk(ope_ver_fk);
		
		Bis_pam bis_pam =getDataByKeyProc(id);;
		
		if( bis_pam == null){
			xpbispamO.setRtn_code(E_XPWOTOOL_NOT_FOUND_RECORDER+"");
			xpbispamO.setRtn_mesg("not found record");
			return xpbispamO;
		}
		
    	this.delete(bis_pam);
		

    	xpbispamO.setRtn_code(RETURN_CODE_OK);
    	xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	public XpbispamO deleteByConditionFnc(XpbispamI xpbispamI){
		XpbispamO xpbispamO = new XpbispamO();
		xpbispamO.setTrx_id("XPBISPAM");
		xpbispamO.setType_id("O");
		XpbispamIA iary = xpbispamI.getIary().get(0);
		String hql ="FROM Bis_pam where  mdl_id_fk='" +  iary.getMdl_id_fk()  + "'";
			hql = hql + " and mdl_typ_fk='" +  iary.getMdl_typ_fk()  + "'";
			hql = hql + " and ope_id_fk='" +   iary.getOpe_id_fk()  + "'";
			hql = hql + " and ope_no_fk='" +   iary.getOpe_no_fk()  + "'";
			hql = hql + " and ope_ver_fk='" +  iary.getOpe_ver_fk()  + "'";
			hql = hql + " and path_id_fk='" +  iary.getPath_id_fk()  + "'";
			hql = hql + " and path_ver_fk='" + iary.getPath_ver_fk()  + "'";
			
		List<Bis_pam> bisPamList =this.find( hql );
		for(Bis_pam bis_pam : bisPamList){
			this.delete(bis_pam);
		}

		xpbispamO.setRtn_code(RETURN_CODE_OK);
		xpbispamO.setRtn_mesg("success");
		return xpbispamO;
	}
	public Bis_pam getDataByKeyProc(Bis_pamId id){
		Bis_pam bis_pam = this.get(id);
		return bis_pam;
	}
	public String getMdlTypByMdlIDProc(String mdl_id ){
		String sql = "SELECT MDL_TYP FROM BIS_MDL_DEF WHERE MDL_ID='"+mdl_id +"'";
		List mdlTypeList =  this.findBySQL(sql);
		if(mdlTypeList.size()==0){
			return null;
		}
		return  mdlTypeList.get(0).toString();
	}
	
}
